#!/usr/bin/env ruby

def include_file(path, output_file)
  f2 = File.open(path)
  filename = path.split("/").last
  output_file.write("FILE #{filename} #{f2.size}\n")
  output_file.write(f2.read)
  output_file.write("\n")
  f2.close
end

f = File.open('built_file_system', 'w')
include_file("#{File.dirname(__FILE__)}/../shell.bin", f)

dirname = "#{File.dirname(__FILE__)}/../file_system_root"
Dir.foreach(dirname) do |item|
  next if item == '.' or item == '..'
  include_file("#{dirname}/#{item}", f)
end

f.close